<?php

defined('_JEXEC') or die;

include_once (JPATH_ROOT."/templates/".$this->template.'/lib/php/jm_mobile-detect.php');
include_once (JPATH_ROOT."/templates/".$this->template.'/lib/php/dj_setup.php');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="ltr" >
<head>
	<jdoc:include type="head" />
	<?php include_once (JPATH_ROOT."/templates/".$this->template.'/lib/php/dj_head.php'); ?>
	<?php
	
	jimport('joomla.filesystem.file');
    jimport('joomla.filesystem.folder');

    if (JFolder::exists(JPATH_ROOT.DS."cache".DS.'tpl-'.$this->template) == false) {
        JFolder::create(JPATH_ROOT.DS."cache".DS.'tpl-'.$this->template);
    }

    $tplParamsHash = md5($this->params->toString());
    
	$customCss = 'style_custom_'.$tplParamsHash.'.css';
	$customCssPath = JPATH_ROOT.DS.'cache'.DS.'tpl-'.$this->template.DS.$customCss;
	$customCssURL = JURI::base().'cache/tpl-'.$this->template.'/'.$customCss;
    if (JFile::exists($customCssPath)) {
        echo '<link href="'.$customCssURL.'" rel="stylesheet" type="text/css" />';
    }
	?>
<meta name="viewport" content="width=device-width; initial-scale=1.0" />
</head>
<body class="webfont">
		<div id="jm-top" style="width: 960px;">
			<div id="jm-logo-sitedesc">
				<h1 id="jm-logo"><a href="<?php echo JURI::base(); ?>" onFocus="blur()" ><img src="<?php echo JURI::base(); ?>templates/osmstudio/images/logo.png" alt="" border="0" /></a></h1>
            </div>
            <?php if(($this->countModules('languages'))) : ?>
            <div class = "language_switching">
                <div id = "languages">
                    <jdoc:include type="modules" name="languages" style="jmmodule" />
                </div>
            </div>
            <?php endif; ?>
		</div>

		<?php if(($this->countModules('dj-menu-top')) || ($this->countModules('header'))) : ?>
		<div id="jm-middle-bg">
			<div id="jm-middle" style="width: 960px;">
				<?php if($this->countModules('dj-menu-top')) : ?>
				<div id="jm-djmenu">
					<jdoc:include type="modules" name="dj-menu-top" style="raw"/>
				</div>
				<?php endif; ?>
				<?php if($this->countModules('header')) : ?>
				<div id="jm-header-wrap">
					<div id="jm-header">
						<jdoc:include type="modules" name="header" style="raw"/>
					</div>
				</div>
				<?php endif; ?>
			</div>
		</div>
		<?php endif; ?>
		<?php if(($this->countModules('main-top1')) || ($this->countModules('main-top2'))) : ?>
		<div id="jm-main-top" style="width: 960px;">
			<div id="jm-main-top-in" class="clearfix">
				<?php if($this->countModules('main-top1')) : ?>
				<div id="jm-main-top1">
					<jdoc:include type="modules" name="main-top1" style="jmmodule"/>
				</div>
				<?php endif; ?>
				<?php echo DJModuleHelper::renderModules('main-top2','jmmodule',3); ?>
			</div>
		</div>
		<?php endif; ?>
		<?php

	 	$detect = new JMMobile_Detect();
            $isMobile = $detect->isMobile();
            $isTablet = $detect->isTablet();
            
            if ($isMobile && !$isTablet) {
                include_once (JPATH_ROOT."/templates/".$this->template.'/lib/php/jm_mobile-layout.php');
            } else {
                include_once (JPATH_ROOT."/templates/".$this->template.'/lib/php/jm_desktop-layout.php');
            }
		?>
		<?php if($this->countModules('bottom')) : ?>
		<div id="jm-bottom" style="width: 960px;">
			<div id="jm-bottom-in" class="clearfix">
				<?php echo DJModuleHelper::renderModules('bottom','jmmodule',3); ?>
			</div>
		</div>
		<?php endif; ?>
	<div id="jm-footer-bg">
		<div id="jm-footer" style="width: 960px;" class="clearfix">
			<?php if(($this->countModules('bottom-menu')) || ($this->countModules('copyrights'))) : ?>
			<div id="jm-footer-lt">
				<?php if($this->countModules('bottom-menu')) : ?>
			    <div id="jm-bottom-menu">
			    	<jdoc:include type="modules" name="bottom-menu" style="raw"/>
			    </div>
			    <?php endif; ?>
				<?php if($this->countModules('copyrights')) : ?>
			    <div id="jm-copyrights">
			    	<jdoc:include type="modules" name="copyrights" style="raw"/>
			    </div>
			    <?php endif; ?>
			</div>
			<?php endif; ?>
			<div id="jm-backtotop">
				<a id="backtotop" href="javascript:void(0)"></a>
			</div>
		</div>
	</div>
</body>
</html>